package com.sinux.sshUser.entity;
/**
 * @author WangGan
 * @version 2017年6月7日 下午3:04:23 
 * 权限类
 */

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "permission")
@DynamicInsert(true)
@DynamicUpdate(true)
public class Permission {
	private String perid;
	private String pername;
	@JsonIgnore
	private Set<Role> roles = new HashSet<Role>();
	
	@Id
	@Column(name = "per_id", unique = true,nullable = false, length = 64)
	public String getPerid() {
		return perid;
	}
	public void setPerid(String perid) {
		this.perid = perid;
	}
	@Column(name = "per_name", nullable = false, length = 64)
	public String getPername() {
		return pername;
	}
	public void setPername(String pername) {
		this.pername = pername;
	}
	@ManyToMany(fetch=FetchType.EAGER)
	@JoinTable(name="re_role_permission",joinColumns={
			@JoinColumn(name="per_id",nullable=false,updatable=false)},inverseJoinColumns={
					@JoinColumn(name="ro_id",nullable=false,updatable=false)})
	public Set<Role> getRoles() {
		return roles;
	}
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}
	
	
}
